import { Component, OnInit, ViewChild, TemplateRef } from '@angular/core';
import { _HttpClient, ModalHelper } from '@delon/theme';
import { STColumn, STComponent, STData } from '@delon/abc';
import { SPage, ColumnType } from '@shared/components/table-page/table-page.component';

@Component({
  selector: 'app-watch-person-list-person-list',
  templateUrl: './person-list.component.html',
})
export class PersonListComponent implements OnInit {
  @ViewChild('st', { static: false }) st: STComponent;
  config: SPage = {
    columns: [
      {
        index: 'id',
        title: '多选',
        type: ColumnType.checkbox,
      },
      {
        index: 'listSource',
        title: '名单来源',
        filter: {
          placeholder: '请输入名单来源',
          type: 'string'
        }
      },
      {
        index: 'name',
        title: '姓名',
        filter: {
          placeholder: '请输入点位姓名',
          type: 'string'
        }
      },
      {
        index: 'papersCode',
        title: '证件号码',
        filter: {
          placeholder: '请输入证件号码',
          type: 'string'
        }
      },
      {
        index: 'mobile',
        title: '手机号码',
        filter: {
          placeholder: '请输入手机号',
          type: 'string'
        }
      },
      {
        index: 'currentAddr',
        title: '现居住地址',
        filter: {
          placeholder: '请输入居住地址',
          type: 'string'
        }
      },
      {
        index: 'personType',
        title: '关注人员类型',
        filter: {
          placeholder: '请输入关注人员类型',
          type: 'string',
        }
      },
      {
        index: 'details',
        title: '详细原因',
        filter: {
          placeholder: '请输入详细原因',
          type: 'string'
        }
      },
      {
        index: 'dateStatus',
        title: '数据状态',
        type: ColumnType.tag,
        tag: {
          1: {text: '有效', color: 'green'},
          2: {text: '无效', color: 'red'},
        },
        filter: {
          type: 'select',
          items: [
            {label: '有效', value: '1'},
            {label: '无效', value: '2'},
          ]
        }
      }
    ],
    showCheckBox: true,
    editBtn:[
      {title:'查看出入记录'},
      {title:'编辑'}
    ],
    data: [
      { name: '李四 ', ssyys: '天威', dateStatus: 1 },
      { name: '王五 ', ssyys: '移动', dateStatus: 2 },
      { name: '王五 ', ssyys: '移动', dateStatus: 1 },
    ]
  }
  constructor(private http: _HttpClient, private modal: ModalHelper) { }

  ngOnInit() { }

  // 根据状态检索不需要被全选的数据
  dataProcess() {
    return this.config.data.map((i: STData, index: number) => {
      return i;
    });
  }
  // 操作区
  operate(e, element: TemplateRef<{}>): void {
    console.log(e);
    
  }
  // 选择数据
  selectChange(e) {
    console.log(e);
    
  }

}
